﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace OnlineBattlemat
{
    public partial class JoinSessionControl : UserControl
    {
        public JoinSessionControl()
        {
            InitializeComponent();

            x_SessionTextBox.Focus();
        }

        private void x_TextBoxes_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                x_JoinButton_Click(sender, new RoutedEventArgs());
            }
        }

        private void x_JoinButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(x_SessionTextBox.Text) || String.IsNullOrEmpty(x_NameTextBox.Text))
            {
                return;
            }


            Page.GetCurrentPage().SessionName = x_SessionTextBox.Text;
			Page.GetCurrentPage().UserName = x_NameTextBox.Text;

			Page.GetCurrentPage().HideDialogs();
        }

        private void x_CancelButton_Click(object sender, RoutedEventArgs e)
        {
			Page.GetCurrentPage().HideDialogs();

        }
    }
}
